|
|
|
|
|
|
|
Private Sub Form_Unload(Cancel As Integer)
Dim res&
If Changed Then
' If any change has been made, give the user
' the option to restore
res = MsgBox("Changes have been made - Restore service states?", _
vbYesNo, "Exit confirmation")
If res = vbYes Then
unloadpending = True
Me.Hide ' Hide the form - no reason to clutter the screen
cmdRestore_Click
Cancel = -1
Changed = False
Exit Sub
End If
End If
Set ServiceCollection = Nothing
Set OriginalStates = Nothing
Set ChangesInProgress = Nothing
Set sc = Nothing
End Sub |
|
|
|
|
|
|
|
|
The timer routine checks the status of each of the services in the ChangesInProgress collection. If the service has entered the desired state, its object is removed from the collection. Once the collection is empty, the user interface is re-enabled and the program re-enters the idle state. |
|
|
|
|
|
|
|
|
' Poll for the completion of the operation in progress
Private Sub Timer1_Timer()
Dim so As ServiceObject
Dim stat As ServiceStatus
Dim target As Long
For Each so In ChangesInProgress
Set stat = so.QueryServiceStatus
' Zero is the restore condition
If TargetState = 0 Then
target = OriginalState(stat.Name)
Else
target = TargetState
End If
If stat.CurrentState = target Then |
|
|
|
|
|